<html>
<head>
<meta charset="UTF-8">
<title>定时调度配置列表</title>
<link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
<script type="text/javascript">

	function doAdd(){
		JLEUtil.createModalWin('新增', 'SSrvsCronConfAdd.html?'+'subsCode='+window.parent.subsCode);
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'SSrvsCronConfUpdate.html?' + 'jobCode=' + row.jobCode);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"jobCode":"' + row.jobCode + '"'+'}');
					$.restfulDelete('../../api/s/srvs/cron/conf', jsonData, function(data) {
						$.messager.alert('提示','记录删除成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','SSrvsCronConfView.html?' + '&jobCode=' + row.jobCode);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doStart(){
		var row = $('#dg').datagrid('getSelected');
		if(row){
			$.restfulPostForm('../../api/s/srvs/cron/conf/do/start',row,function(data){
				if(data.code == '0') {
					$.messager.alert('提示', data.message,'success');
				} else {
					$.messager.alert('提示', data.message,'error');
				}
				$('#dg').datagrid('reload');
			});
		}else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doDisable(){
		var row=$('#dg').datagrid('getSelected');
		if(row){
			$.restfulPostForm('../../api/s/srvs/cron/conf/do/false',row,function(data){
				if(data.code == '0') {
					$.messager.alert('提示', data.message,'success');
				} else {
					$.messager.alert('提示', data.message,'error');
				}
				$('#dg').datagrid('reload');
			});
		}else{
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doInitiate(){
		var row=$('#dg').datagrid('getSelected');
		if(row){
			$.restfulPostForm('../../api/s/srvs/cron/conf/do/initial',row,function(data){
				if(data.code == '0') {
					$.messager.alert('提示', data.message,'success');
				} else {
					$.messager.alert('提示', data.message,'error');
				}
				$('#dg').datagrid('reload');
			});
		}else{
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doShowHistory(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','SSrvsCronHisList.html?' + 'jobCode=' + row.jobCode);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};	
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',title:''" style="height: 40px; ">
	<form id="searchForm">
		<table>
			<tr>
				<td class="searchTd">&nbsp;定时作业编号：</td>
				<td><input name="jobCode" id="jobCode"/></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.queryForm('searchForm','dg','../../api/s/srvs/cron/confs');">查找</a></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
			</tr>
		</table>
	</form>
</div>
<div data-options="region:'center',split:false">
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:95%"
	   data-options="singleSelect:true,collapsible:true,url:'../../api/s/srvs/cron/confs/',queryParams:{agentId : $.getUrlParam('agentId'),subsCode:window.parent.subsCode},method:'post'"
	   toolbar="#tb"
		title="Load Data" 
		rownumbers="true" pagination="true" pageSize="20">
		<thead>
			<tr>
				<th data-options="field:'jobCode',resizable:true" >定时作业编号</th>
				<th data-options="field:'jobDesc',resizable:true" >定时作业描述</th>
				<th data-options="field:'jobClassType',resizable:true" formatter="formatter_JOB_CLASS_TYPE">作业类类型</th>
				<th data-options="field:'jobClass',resizable:true" >作业实现类</th>
				<th data-options="field:'jobMethod',resizable:true" >作业类方法</th>
				<th data-options="field:'cronExpression',resizable:true" >执行周期</th>
				<th data-options="field:'againTime',resizable:true" >失败重试次数</th>
				<th data-options="field:'retrySecond',resizable:true" >重试间隔秒数</th>
				<th data-options="field:'agentId',resizable:true" >服务节点标识</th>
				<th data-options="field:'jobState',resizable:true" formatter="formatter_JOB_STATE">作业状态</th>
				<th data-options="field:'lastExecuteTime',resizable:true" >上一次执行时间</th>
				<th data-options="field:'nextExecuteTime',resizable:true" >下一次执行时间</th>
				<th data-options="field:'costTime',resizable:true" >耗时（秒）</th>
				<th data-options="field:'subsCode',resizable:true" >所属系统</th>
				<th data-options="field:'remark',resizable:true" >备注</th>
			</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true">新增</a>
		<a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
		<a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
		<a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">查看</a>
		<a href="javascript:doInitiate()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">启用</a>
		<a href="javascript:doDisable()" class="easyui-linkbutton" iconCls="icon-no" plain="true">禁用</a>
		<a href="javascript:doStart()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">手工发起</a>
		<a href="javascript:doShowHistory()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">运行历史</a>
	</div>
</div>
</body>
</html>
